package com.test.springboot3.springboot3testdemo1.listener;

import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.availability.AvailabilityChangeEvent;
import org.springframework.boot.availability.ReadinessState;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： liuziyang
 * @date： 2024/7/25-22:17
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
@Slf4j
@Component
public class JavaStackListener implements ApplicationListener<AvailabilityChangeEvent> {
  @Override
  public void onApplicationEvent(AvailabilityChangeEvent event) {
    log.info("监听到事件{}", event);
    if (Objects.equals(ReadinessState.ACCEPTING_TRAFFIC, event.getState())) {
      log.info("应用启动已完成，可以接收请求了...");
    }
  }
}
